package com.apes.crm.callCenter.model;

import com.apes.framework.jpa.BaseModel;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.scm.masterdata.enumeration.model.Enumeration;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

/**
 * 功能：客诉单
 *
 * @author Biebi
 * @create 2018-7-11 11:42:47
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = CustomComplainSource.CONST_TABLE_NAME)
public class CustomComplainSource extends BaseModel {

    public static final String CONST_TABLE_NAME = "crm_custom_complain_source";

    @Id
    @Column(name = "id")
    @ApesGenerator(code = CONST_TABLE_NAME, name = "来源编码")
    private String id;


    @ManyToOne(optional = false)
    @JoinColumn(name = "custom_complain_id", referencedColumnName = "id", nullable = false)
    @Comment("客诉单号")
    private CustomComplain customComplain;

    @Comment("来源类型")
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "complain_source_type", referencedColumnName = "id", nullable = false)
    private Enumeration complainSourceType;

    @Comment("来源单号")
    @Column(name = "complain_source_id", length = 200, nullable = false)
    private String complainSourceId;

    @Comment("备注")
    @Column(name = "remark", length = 4000)
    private String remark;
}
